package com.test;

public class Constant {

	public static final String CHARSET = "utf-8";
	public static final String JSON_CONTENTTYPE = "application/json";
	public static final String EQ = "=";
	public static final String QUESTION = "?";
	public static final String SLASH = "/";
	public static final String AND = "&";
	public static final String EMPTY_STRING = "";
	public static final String DOT = ".";

	// SPI加载类信息
	public static final String BEANOPT_TYPE = "beanoptType";
	public static final String JSON_TYPE = "jsonType";
	public static final String WORKID_TYPE = "workIdType";
	public static final String SERIALIZATION_TYPE = "serializationType";
	public static final String LOCK_TYPE = "lockType";
	public static final String LEADER_TYPE = "leaderType";
	public static final String CACHE_TYPE = "cacheType";
	public static final String REDIS_IMPL = "redisImpl";
	public static final String ZOOKEEPER_IMPL = "zookeeperImpl";
	public static final String MQ_TYPE = "mqType";
	public static final String RABBIT_IMPL = "rabbitImpl";
	public static final String METHOD_DISPATCH_IMPL = "methoddispatch";
	public static final String ES_IMPL = "esImpl";
	public static final String MONGO_IMPL = "mongoImpl";

	//rabbit配置信息
	public static final String RABBIT_PROP_LOCATION = "rabbit.properties";
	public static final String RABBIT_PROP_NAMES = "rabbit.names";
	public static final String RABBIT_PROP_DEFAULT_NAME = "default"; // 默认的rabbitmq配置name
	public static final String MQ_PROP_DEFAULT_CONFIGNAME = "default"; // 默认的mq配置名
	public static final String MQ_PROP_DEFAULT_GROUPNAME = "defaultgroup"; // 默认的groupid
	public static final String MQ_PROP_DEFAULT_TOPIC = "defaulttopic"; // 默认的topic
	public static final String RABBIT_PROP_SERVER = "rabbit.server";
	public static final String RABBIT_PROP_SERVER_PORT = "rabbit.server.port";
	public static final String RABBIT_PROP_SERVER_VIRTUALHOST = "rabbit.server.virtualHost";
	public static final String RABBIT_PROP_SERVER_USERNAME = "rabbit.server.username";
	public static final String RABBIT_PROP_SERVER_PASSWORD = "rabbit.server.password";
	public static final String RABBIT_PROP_SERVER_AUTO_RECOVERY = "rabbit.server.automatic_recovery_enabled";
	public static final String RABBIT_PROP_SERVER_AUTO_DECLARE = "rabbit.server.automatic_declare_enabled"; // 是否可以自动创建主题
	public static final boolean RABBIT_PROP_SERVER_AUTO_RECOVERY_DEFAULT = true; // rabbit.server.automatic_recovery_enabled的默认值
	public static final boolean RABBIT_PROP_SERVER_AUTO_DECLARE_DEFAULT = true; // rabbit.server.automatic_declare_enabled的默认值
	public static final String RABBIT_PROP_EXCHANGE_PREFIX = "rabbit.exhange.prefix"; // exhange前缀
	public static final String RABBIT_PROP_QUEUE_PREFIX = "rabbit.queue.prefix"; // queue前缀

	//redis配置信息
	public static final String REDIS_PROP_LOCATION = "redis.properties";
	public static final String REDIS_PROP_CLUSTER_TYPE = "redis.clusterType";
	public static final String REDIS_PROP_CLUSTER_TYPE_DEFAULT = "sentinel"; // redis.clusterType的默认值
	public static final String REDIS_PROP_SERVER = "redis.server";
	public static final String REDIS_PROP_SERVER_COMPATIBILITY = "redis.sentinel.server"; // 用于解决和老配置文件的兼容性问题
	public static final String REDIS_PROP_PASSWORD = "redis.password";
	public static final String REDIS_PROP_DATABASE = "redis.databases";
	public static final int REDIS_PROP_DATABASE_DEFAULT = 4; // redis.databases的默认值
	public static final String REDIS_PROP_MASTERNAME = "redis.sentinel.masterName";
	public static final String REDIS_PROP_MASTERNAME_DEFAULT = "master1"; // redis.sentinel.masterName的默认值
	public static final String REDIS_PROP_MAXATTEMPTS = "redis.maxAttempts";
	public static final int REDIS_PROP_MAXATTEMPTS_DEFAULT = 2; // redis.maxAttempts的默认值
	public static final String REDIS_PROP_POOL_MAXTOTAL = "redis.pool.maxtotal";
	public static final int REDIS_PROP_POOL_MAXTOTAL_DEFAULT = 20; // redis.pool.maxtotal的默认值
	public static final String REDIS_PROP_POOL_MAXIDLE = "redis.pool.maxIdle";
	public static final int REDIS_PROP_POOL_MAXIDLE_DEFAULT = 10; // redis.pool.maxIdle的默认值
	public static final String REDIS_PROP_POOL_MINIDLE = "redis.pool.minIdle";
	public static final int REDIS_PROP_POOL_MINIDLE_DEFAULT = 10; // redis.pool.minIdle的默认值
	public static final String REDIS_PROP_CONN_TIMEOUT = "redis.connectionTimeout";
	public static final int REDIS_PROP_CONN_TIMEOUT_DEFAULT = 100; // redis.connectionTimeout的默认值
	public static final String REDIS_PROP_SOTIMEOUT = "redis.soTimeout";
	public static final int REDIS_PROP_SOTIMEOUT_DEFAULT = 500; // redis.soTimeout的默认值
	public static final String REDIS_PROP_POOL_MAXWAIT_MILLIS = "redis.pool.maxWaitMillis";
	public static final int REDIS_PROP_POOL_MAXWAIT_MILLIS_DEFAULT = 2000; // redis.pool.maxWaitMillis的默认值
	public static final String REDIS_PROP_APPNAME = "redis.app";

	//zk配置信息
	public static final String ZK_PROP_LOCATION = "zookeeper.properties";
	public static final String ZK_PROP_SERVER = "zookeeper.server";
	public static final String ZK_SERVER_PRIFIX = "zookeeper://";
	public static final String ZK_PROP_APPNAME = "zookeeper.app";
	public static final String ZK_PROP_LEADERNODENAME = "zookeeper.leadername";
	public static final String ZK_PROP_WORKIDNODENAME = "zookeeper.workIdname"; // workId在zk上对应的namespace
	public static final String DEFAULT_WORKIDNODENAME = "idgen_work"; // workId在zk上对应的默认namespace
	public static final String ZK_PROP_WORKIDMAXIDLEDAYS = "zookeeper.workIdidleseconds"; // 如果在zk上的wokId对应的节点有workIdidledays天没有被更新，就删除该节点
	public static final Integer DEFAULT_WORKIDMAXIDLESECONDS = 60 * 60 * 24 * 5; // 如果5天都没有更新时间，就认为该机器下线，在zk上删除该workId节点
	public static final String ZK_PROP_MAXWORKID = "zookeeper.maxWorkId"; // workId最大值
	public static final Long DEFAULT_MAXWORKID = 1000l; // workId最大值

	//分布式锁
	public static final String LOCK_DEFAULT = "o2olock";

	//链路编排配置
	public static final String TRACE_SCHEDULE_PROP_LOCATION = "traceshedule.properties";
	public static final String TRACE_SCHEDULE_TYPE = "traceScheduleType";
	public static final String TRACE_SCHEDULE_TYPE_DEFAULT = "traceScheduleMq";
	public static final String TRACE_SCHEDULE_MQ_NAME = "traceSchedule"; // 用于链路编排的默认mq集群名称

	//数据源配置
	public static final String DATASOURCE_LOCATION = "jdbc-loc.properties";
	public static final String TRACE_SCHEDULE_DATASOURCE_PREFIX = "consistency";
	public static final String CONSISTENCY_TRANSACTION_DATASOURCE_PREFIX = TRACE_SCHEDULE_DATASOURCE_PREFIX;

	//事务版本号，用于解决并发冲突
	public static final String CONSISTENCY_TRANSACTION_MAPPER_LOCATION = "com.webflux.first.dao";
	//最终一致性
	public static final String CONSISTENCY_MAPPER_LOCATION = "com.ziroom.common.api.consistency.dao";
	public static final Byte CONSISTENCY_RETRY_NUM = 6; // 重试次数
	public static final Byte CONSISTENCY_RETRY_INTERVAL = 20; // 重试时间间隔: 20, 40, 60, 80, 100, 120
	public static final String CONSISTENCY_DOMAIN_TRACE_SCHEDULE = "traceSchedule_consistency_event"; // traceSchedule的domain，用于补偿回调(消息编排用于最终一致性保障的业务标识)
	public static final String CONSISTENCY_DOMAIN_DELAY_EXECUTE = "delayexecute_consistency_event"; // 延迟任务的domain，用于补偿回调(延迟任务用于最终一致性保障的业务标识)
	public static final Byte CONSISTENCY_LOCK_RETRY_TIMEOUT = 2; // 如果链路加锁，获取锁的超时时间
	public static final Integer CONSISTENCY_LOCK_EXPIRE_TIME = 10; // 如果链路加锁，锁的最长有效期
	public static final String CONSISTENCY_RETRY_ENABLED = "consistencyRetryEnable"; // 是否开启传输保障

	//延迟消息实现方式
	public static final String DELAY_PROP_LOCATION = "distributedDelayExecute.properties"; // 配置文件位置
	public static final String DELAY_PROP_TASKFLAG = "taskFlag"; // 任务标识: 用于区分不同的项目的任务
	public static final String DELAY_MNGTYPE = "delay.type";
	public static final String DELAY_JVM_MNGTYPE = "delay.jvm.type";
	public static final String CONSISTENCY_DELAY = "delayExecute"; // 延迟任务的传输保障里的bizKey
	public static final Byte DELAY_CONSISTENCY_START_RETRY_NUM = 6; // 延迟任务的传输保障起始重试次数，也就是只重试一次
	public static final String DELAY_MESSAGE_STORE_QUEUENAME = "delayMessageStoreQueue"; // 延迟任务最终执行的mq消息的前缀

	//mq
	public static final String CONSUMER_EXECUTE_BEFORE = "consumer_execute_before_event"; // mq消费者消费数据前的事件
	public static final String CONSUMER_EXECUTE_AFTER = "consumer_execute_after_event"; // mq消费者消费数据后的事件
	public static final String PRODUCER_POOL_MINTHREADNUM = "producer.pool.minThreadNum"; // 发送者线程池最小核心数
	public static final String PRODUCER_POOL_SPRING_BEANNANE_PRIFIX = "producer.pool."; // 发送者线程池在spring里的bean name前缀
	public static final String PRODUCER_POOL_MAXTHREADNUM = "producer.pool.maxThreadNum"; // 发送者线程池最大核心数
	public static final String PRODUCER_POOL_KEEPALIVESECOND = "producer.pool.keepAliveSecond"; // 最大空闲存活时间
	public static final int PRODUCER_POOL_MINTHREADNUM_DEFAULT = Runtime.getRuntime().availableProcessors() + 1; // 发送者线程池最小核心数默认值
	public static final int PRODUCER_POOL_MAXTHREADNUM_DEFAULT = Runtime.getRuntime().availableProcessors() + 1; // 发送者线程池最大核心数默认值
	public static final int PRODUCER_POOL_KEEPALIVESECOND_DEFAULT = 60; // 最大空闲存活时间默认值

	//Handlers
	public static final String HANDLER_EXECUTE_AFTER = "handler_execute_after_event"; // Handlers注解的类里的方法执行后的事件
	public static final String HANDLER_EXECUTE_EXCEPTION = "handler_execute_exception_event"; // Handlers注解的类里的方法执行后的异常事件

	//方法分发
	public static final String METHOD_DISPATCHER_MAP_KEY = "methodDispatcherMapKey"; // 初始化好的方法对象map缓存在map中的key

	//id生成器
	public static final String UIDGENERATOR_JVM = "jvm"; // jvm内部唯一id的spi实现标识
	public static final String UIDGENERATOR_DISTRIBUTE = "distribute"; // 全局内部唯一id的spi实现标识
	public static final String UIDGENERATOR_DATASOURCE_PREFIX = "distributed.idgenerator";
	public static final String UIDGENERATOR_MAPPER_LOCATION = "com.ziroom.common.uid.worker.dao";
	public static final String UIDGENERATOR_PROP_LOCATION = "uidgenerator.properties";
	public static final String UIDGENERATOR_PROP_TIMEBITS = "timeBits";
	public static final String UIDGENERATOR_PROP_WORKBITS = "workerBits";
	public static final String UIDGENERATOR_PROP_SEQBITS = "seqBits";
	public static final Integer DEFAULT_TIMEBITS = 28;
	public static final Integer DEFAULT_WORKBITS = 22;
	public static final Integer DEFAULT_SEQBITS = 13;

	public static final int SNAKE_DEFAULT_WORKID = 7; // 雪花算法默认机器id

	// 链路追踪
	public static final String TRACER_BEANNAME = "selfSofaTracer"; // 用于判断是否开启的beanName
	public static final String TRACER_MQ_CLIENT_NAME = "clientTracer"; // mq的生产者实现
	public static final String TRACER_MQ_SERVER_NAME = "serverTracer"; // mq的消费者实现
	public static final String TRACER_ASYNC_CLIENT_NAME = "asyncClientTracer"; // 异步调用者实现
	public static final String TRACER_ASYNC_SERVER_NAME = "asyncServerTracer"; // 异步被调用者实现
	public static final String TRACER_SQL_CLIENT_NAME = "sqlClientTracer"; // sql调用者实现
	public static final String TRACER_REDIS_CLIENT_NAME = "redisClientTracer"; // redis调用者实现
	public static final String TRACER_ES_CLIENT_NAME = "esClientTracer"; // es调用者实现
	public static final String TRACER_MONGO_CLIENT_NAME = "mongoClientTracer"; // mongo调用者实现

	public static final String TRACER_REPORTER_LOG_TYPE = "tracerReporterLogType"; // reporter实现类型
	public static final String TRACER_DATASOURCE_PREFIX = "tracer";
	public static final String TRACER_MAPPER_LOCATION = "com.ziroom.common.tracer.worker.dao";


	// 线程池
	public static final int DEFAULT_KEEPALIVE_SECONDS = 60;
	public static final String ASYNC_ANNO_DEFAULT_POOL_BEANNAME = "tracerAsyncThreadPool"; // @Async注解使用的默认线程池的beanName;

	// es配置
	public static final String ES_PROP_LOCATION = "elasticsearch.properties";
	public static final String ES_PROP_CLUSTER_ADDRESS = "elasticsearch.addresses"; // 集群地址
	public static final String ES_PROP_CLUSTER_NAME = "elasticsearch.clusterName"; // 集群名称
	public static final String ES_PROP_TRANSPORTSNIFF = "elasticsearch.transportSniff"; // 是否开启集群地址嗅探
	public static final boolean ES_PROP_TRANSPORTSNIFF_DEFAULT = true;

	// MongoDB配置
	public static final String MONGO_PROP_DEFAULT_PREFIX = "mongo.";
	public static final String MONGO_PROP_LOCATION = "mongo.properties";
	public static final String MONGO_PROP_CLUSTER_TYPE = "clusterType"; // 集群类型
	public static final String MONGO_PROP_CLUSTER_TYPE_DEFAULT = "replica"; // 默认集群类型为 主从复制
	public static final String MONGO_PROP_REPLICA_READ_DB_URL = "replica.read.url"; // 从库地址
	public static final String MONGO_PROP_REPLICA_WRITE_DB_URL = "replica.write.url"; // 主库地址
	public static final String MONGO_PROP_DB_NAME = "dbName"; // 数据库名称
	public static final String MONGO_PROP_MAXPOOLSIZE = "maxPoolSize"; // 链接池数量
	public static final int MONGO_PROP_CONNECTSPERHOST_DEFAULT = 20; // 链接池数量
	public static final String MONGO_PROP_CONNECTTIMEOUTMS = "connectTimeoutMS"; // 连接超时时间
	public static final String MONGO_PROP_SOCKETTIMEOUTMS = "socketTimeoutMS"; // 读写超时时间
	public static final String MONGO_PROP_MAXIDLETIMEMS = "maxIdleTimeMS"; // 最大空闲时间
	public static final String MONGO_PROP_MAXLIFETIMEMS = "maxLifeTimeMS"; // 连接最大生命周期

}
